package com.wanmait.wanmarecruit.config;

import com.wanmait.wanmarecruit.interceptor.ManageLoginInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import javax.annotation.Resource;

@Configuration
public class ManageConfig implements WebMvcConfigurer {
    @Resource
    private ManageLoginInterceptor manageLoginInterceptor;

    @Override
    public void addCorsMappings(CorsRegistry registry) {
        registry.addMapping("/**")
                .allowedOrigins("*")
                .allowedMethods("*")
                .allowedHeaders("*")
                .maxAge(3600);//3600秒 不用再次发送预检请求 OPTIONS
    }

//    @Override
//    public void addInterceptors(InterceptorRegistry registry) {
//        registry.addInterceptor(manageLoginInterceptor).addPathPatterns("/manage/**").excludePathPatterns("/manage/tryLogin","/manage/code","/manage/checkCode");
//    }
}
